<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>新增便民电话</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
    <script src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form" style="margin-left: 30%">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>ID</label>
                <div class="layui-input-inline">
                    <input type="text" id="pid" maxlength="11" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>电话号</label>
                <div class="layui-input-inline">
                    <input type="text" id="pphone" maxlength="11" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>姓名</label>
                <div class="layui-input-inline">
                    <input type="text" id="pname" maxlength="5" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>性别</label>
                <div class="layui-input-inline">
                    <input type="text" id="psex" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>年龄</label>
                <div class="layui-input-inline">
                    <input type="text" id="page" maxlength="3"  autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>职位</label>
                <div class="layui-inline layui-show-xs-block">
                    <select name="cateid" id="zw">
                        <option value="0">职位分类</option>
                        <option value="1">社区服务站站长</option>
                        <option value="2">社会福利与劳动保障专职工作者</option>
                        <option value="3">人口庄计生与公共卫生专职工作者</option>
                        <option value="4">社区治安综合治理专职工作者</option>
                        <option value="5">社区环境环保专职工作者</option>
                        <option value="6">社区公共文化专职工作者</option>
                        <option value="7">社区综合事务专职工作者</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" id="butt" lay-submit="">增加</button></div>
        </div>
    </div>
</div>
</body>

</html>
<script>
    layui.use(['table','jquery','layer'], function(){
        var table = layui.table;
        var $=layui.jquery;
        layer = layui.layer;
        $.ajax({
            type:'GET',
            url:"http://localhost:8080/api/bmdhcx",
            data:{"id":sessionStorage.getItem("pid")},
            headers:{
                token:localStorage.getItem("token")
            },
            datatype: "json",
            success:function (data){
                let pid=sessionStorage.getItem("pid")
                let pphone=sessionStorage.getItem("pphone")
                let pname=sessionStorage.getItem("pname")
                let psex=sessionStorage.getItem("psex")
                let page=sessionStorage.getItem("page")
                let zw=sessionStorage.getItem("zw")
                $("#pid").val(pid);
                $("#pphone").val(pphone);
                $("#pname").val(pname);
                $("#psex").val(psex);
                $("#page").val(page);
                $("#zw :selected").text(zw);
            }
        })
    })

    $("#butt").click(function (){
        layui.use(['table','jquery','layer'], function(){
            var table = layui.table;
            var $=layui.jquery;
            var layer=layui.layer;
            let pid= $("#pid").val();
            let pphone= $("#pphone").val();
            let pname= $("#pname").val();
            let psex=$("#psex").val();
            let page= $("#page").val();
            let zw= $("#zw").val();
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/api/bmdhxg",
                data:{"pId":pid,"pPhone":pphone,"pName":pname,"pSex":psex,"pAge":page,"pPosition":zw},
                headers:{
                    token:localStorage.getItem("token")
                },
                datatype: "json",
                success:function (data){
                    if ($("#zw option:selected").text("职位分类")){
                        layer.msg('请选择职位!',{
                            icon:2
                            ,time:800
                        })

                    }
                    if (data!=""){
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg('便民电话修改成功!',{
                            icon:1
                            ,time:800
                        },function (){
                            parent.layer.close(index);//关闭当前页
                        });
                    }
                }
            })
        })
    })
</script>